﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HalalCheck.Resources;
using Xamarin.Forms;

namespace HalalCheck.View
{
    public class LiveMadinaPage : BasePage
    {
        private WebView _liveWebView;

        public LiveMadinaPage()
        {
            Title = HalalStrings.LiveMadina;

            var layout = new RelativeLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,

            };
            var halalchecklogo = new Image
            {
                Source = "centerlogo.png"
            };
            layout.Children.Add(halalchecklogo, Constraint.RelativeToParent((p) => (p.Bounds.Width - 200) / 2), Constraint.RelativeToParent((p) => (p.Bounds.Height - 200) / 2), Constraint.RelativeToParent((p => 200)), Constraint.RelativeToParent((p) => 200));

            _liveWebView = new WebView();
            _liveWebView.SetBinding(WebView.SourceProperty, new Binding("Url"));

            layout.Children.Add(_liveWebView, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent((p) => p.Bounds.Width), Constraint.RelativeToParent((p) => p.Bounds.Height));

            Content = layout;
        }

        protected override void OnDisappearing()
        {
            base.OnDisappearing();
            _liveWebView.Source = "";
        }
    }
}
